#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Software: PyCharm
# @Version : Python-
# @Author  : Shengji He
# @Email   : hsjbit@163.com
# @File    : predict_hsj.py
# @Time    : 2020/1/13 14:15
# @Description:


def predict_with_lm(file):
    print("Loading model with language model...")
    import beamdecode
    print("Model loaded")
    return beamdecode.predict(file)


def predict_without_lm(file):
    from models.conv import GatedConv
    print("Loading model with language model...")
    model = GatedConv.load("/home/admin717/test_hsj/LFASR/pretrained/gated-conv.pth")
    print("Model loaded")
    return model.predict(file)


if __name__ == '__main__':
    file = 'test.wav'
    text1 = predict_without_lm(file)
    text2 = predict_with_lm(file)
    print('Gold Standard: 由太原市南郊区寇庄村农民投资数百万元建设的平阳极贸市场因管理等诸多方面的原因已停业一年')
    print('Without lm   : %s' % text1)
    print('With lm      : %s' % text2)
    print('done')
